package task;

import java.util.Scanner;

public class Task5_1 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("台阶数：");
        int n = input.nextInt();
        System.out.println("跳法种数:" + frogJump(n));
        System.out.println("跳法种数:" + frogJump2(n));

    }
    public static  int frogJump2(int n){
        if(n == 1 || n == 2){
            return n;
        }
        int a = 1;
        int b = 2;
        int c = 0;
        for (int i = 3; i <= n; i++) {
            c = a + b;
            a = b;
            b = c;
        }
        return c;
    }
    public static  int frogJump(int n){
        if(n == 1 || n == 2){
            return n;
        }
        return frogJump(n -1) + frogJump(n - 2);
    }

}
